$OpenBSD: patch-etherping_c,v 1.3 2013/12/06 11:53:05 jca Exp $
--- etherping.c.orig	Tue Apr 18 03:52:53 2000
+++ etherping.c	Fri Dec  6 12:47:51 2013
@@ -13,7 +13,6 @@ int getIPfromPkt(char *pkt, int len, char *holder);
 int isUniqueMachineResult(struct result *, char *);
 int insertMachine(struct result *, char *);
 char *ether_ntoa (struct ether_addr *e);
-struct ether_addr *ether_aton (char *s);
 
 
 int etherping_done=0;
@@ -48,6 +47,7 @@ int etherping(HDEV fd, char *ether_addr, char *target_
   struct ether_addr e_src;
   struct in_addr iaddr;
   char promiscGuy[MAX_LEN];
+  static char *dev = NULL;
 
   fromlen = sizeof(from);
 
@@ -92,7 +92,8 @@ int etherping(HDEV fd, char *ether_addr, char *target_
 #else
   snprintf(ether_src, sizeof(ether_src), "%s", ether_ntoa(&e_src));
 #endif
-  getipaddr(DEVICENAME, &iaddr);
+  if (!dev) dev = strdup(pcap_lookupdev(NULL));
+  getipaddr(dev, &iaddr);
   icmp_pack = (char *)make_icmp_echo(ether_addr, ether_src, target_ip, inet_ntoa(iaddr), ident, &len);
 /*   send_raw_frame(fd, icmp_pack, len, 0);  */
 
